import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;

public class demo35 {
    public static void main(String[] args) throws InterruptedException {
        //子任务划分出10个
        CountDownLatch count = new CountDownLatch(10);
        //new 出 10 个线程 来分别执行每个任务
        for (int i = 0; i < 10; i++) {
            final int finalI = i;
            new Thread(() -> {
                //描述要执行的任务
                System.out.println("执行的任务: " + finalI);
                //执行完子任务countDown一下
                count.countDown();
            }).start();
        }
        //等待所有子任务执行完
        count.await();
        System.out.println("所有子任务执行完, 整个任务执行完毕");
    }
}
